<!doctype html>
<html>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width initial-scale=1'>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link rel="stylesheet" href="index.css?v=1598620979053"/>
    <title>api doc</title>
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1">
    <div class="book-summary">
        <div id="book-search-input"><input id="search" type="text" placeholder="Type to search"></div>
        <nav role="navigation">
            <ul class="summary">
                <li><ul id="reference">API Reference</ul></li>
                <li class="divider"></li>
                <div id="doc">
                    <li class="chapter " data-level="bf96ff3caa364a37a099b5080ddcfa8e" data-path="bf96ff3caa364a37a099b5080ddcfa8e.html">
                       <a href="javascript:void(0)" onclick="go('bf96ff3caa364a37a099b5080ddcfa8e', '&lt;p&gt;app端接口测试&lt;/p&gt;');">1 &lt;p&gt;app端接口测试&lt;/p&gt;</a>
                        <ul class="articles">
                            <li class="chapter " data-level="bf96ff3caa364a37a099b5080ddcfa8e" data-path="bf96ff3caa364a37a099b5080ddcfa8e.html">
                              <a href="javascript:void(0)" onclick="go('bf96ff3caa364a37a099b5080ddcfa8e', '<p>app测试</p>');">1.1&nbsp;<p>app测试</p></a></li>
                        </ul>
                    </li>
                </div>

                 <li class="chapter " data-level="dict" data-path="dict.html">
                      <a href="dict.html?v=1598620979053" target="book_iframe">2. 数据字典</a>
                      <ul class="articles">
                         <li class="chapter " data-level="订单状态" data-path="dict.html">
                         <a href="dict.html?v=1598620979053" target="book_iframe">2.1 订单状态</a></li>
                         <li class="chapter " data-level="订单状态1" data-path="dict.html">
                         <a href="dict.html?v=1598620979053" target="book_iframe">2.2 订单状态1</a></li>
                         <li class="chapter " data-level="性别字典" data-path="dict.html">
                         <a href="dict.html?v=1598620979053" target="book_iframe">2.3 性别字典</a></li>
                     </ul>
                 </li>
                <li class="divider"></li>
                <li class="footer_link"><a href="https://github.com/shalousun/smart-doc" target="_blank" class="gitbook-link">Created by smart-doc</a>
                </li>
            </ul>
        </nav>
    </div>
    <div id="book-body" class="book-body" height="100%">
        <iframe src="bf96ff3caa364a37a099b5080ddcfa8e.html?v=1598620979053" frameborder="0" id="book_iframe" name="book_iframe" width="100%"></iframe>
    </div>
</div>

<script type="text/javascript">
    var api = [];

    function changeFrameHeight() {
        var ifm = document.getElementById("book_iframe");
        ifm.height = document.documentElement.clientHeight;
    }

    function toPage() {
        var page = localStorage.getItem('page');
        var title = localStorage.getItem('title');
        if(page) {
           var iframe = document.getElementById("book_iframe");
           iframe.src = page + ".html";
           var obj = iframe.contentWindow;
           obj.onload = function(){
           var h2 = obj.document.getElementsByTagName('h2');
               for(j = 0; j < h2.length; j++) {
                   var dom = h2[j];
                   if(dom.innerText == title){
                       obj.scroll(0, dom.offsetTop);
                       break;
                   }
               }
           }
        }
    }

    toPage();

    function go(alias, desc) {
        console.log(alias, desc);
        var iframe = document.getElementById("book_iframe");
        var page = localStorage.getItem('page');

        if(page != alias){
            iframe.src = alias + ".html";
        }

        localStorage.setItem('page', alias);
        localStorage.setItem('title', desc);

        setTimeout(() => {
            var obj = iframe.contentWindow;
            var h2 = obj.document.getElementsByTagName('h2');
            for(j = 0; j < h2.length; j++) {
                var dom = h2[j];
                if(dom.innerText == desc){
                    obj.scroll(0, dom.offsetTop);
                    break;
                }
            }
         }, 200)
    }

    changeFrameHeight();
    setInterval(function(){changeFrameHeight(); }, 500);

    document.onkeydown = keyDownSearch;
    function keyDownSearch(e) {
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13) {
            var search = document.getElementById('search');
            var searchArr = [];
                searchArr.push({
                    alias: 'bf96ff3caa364a37a099b5080ddcfa8e',
                    order: '1',
                    desc: '&lt;p&gt;app端接口测试&lt;/p&gt;',
                    list: []
                })
                api.push({
                    alias: 'bf96ff3caa364a37a099b5080ddcfa8e',
                    order: '1',
                    desc: '&lt;p&gt;app端接口测试&lt;/p&gt;',
                    list: []
                })
                    api[0].list.push({
                        order: '1',
                        desc: '<p>app测试</p>',
                    });
                    if('<p>app测试</p>'.indexOf(search.value) > -1) {
                        searchArr[0].list.push({
                            order: '1',
                            desc: '<p>app测试</p>',
                        });
                    }
            var searchResult = searchArr.filter(obj => obj.list.length > 0);
            if(searchResult.length > 0) {
                var html = '';
                for(j = 0; j < searchResult.length; j++) {
                   html += '<li class="chapter " data-level="' + searchResult[j].alias + '" data-path="' + searchResult[j].alias + '.html">';
                   html += '    <a href="javascript:void(0)" onclick="go(\'' + searchResult[j].alias + '\', \'' + searchResult[j].desc + '\');">' + searchResult[j].order + ' ' + searchResult[j].desc + '</a>';


                   html += '    <ul class="articles">';

                   var doc = searchResult[j].list;
                   for(m = 0; m < doc.length; m++) {
                         html += '    <li class="chapter " data-level="' + searchResult[j].alias + '" data-path="' + searchResult[j].alias + '.html">';
                         html += '      <a href="javascript:void(0)" onclick="go(\'' + searchResult[j].alias + '\', \'' + doc[m].desc + '\');">' + searchResult[j].order + '.' + doc[m].order + ' ' + doc[m].desc + '</a></li>';
                         html += '    </li>';
                   }
                   html += '</ul>';
                }
                document.getElementById('doc').innerHTML = html;
            } else {
                if(search.value == '') {
                    var html = '';
                    for(j = 0; j < api.length; j++) {
                       html += '<li class="chapter " data-level="' + api[j].alias + '" data-path="' + api[j].alias + '.html">';
                       html += '    <a href="javascript:void(0)" onclick="go(\'' + api[j].alias  + '\', \'' + api[j].desc + '\');">' + api[j].order + ' ' +api[j].desc + '</a>';
                       html += '    <ul class="articles">';

                       var doc = api[j].list;
                       for(m = 0; m < doc.length; m++) {
                             html += '    <li class="chapter " data-level="' + searchResult[j].alias + '" data-path="' + searchResult[j].alias + '.html">';
                             html += '      <a href="javascript:void(0)" onclick="go(\'' + api[j].alias  + '\', \'' + doc[m].desc + '\');">' + searchResult[j].order + '.' + doc[m].order + ' ' + doc[m].desc + '</a></li>';
                             html += '    </li>';
                       }
                       html += '</ul>';
                    }

                    document.getElementById('doc').innerHTML = html;
                } else {
                    document.getElementById('doc').innerHTML = '';
                }
            }
        }
    }
</script>
</body>
</html>